import {
  axios
} from '@/utils/request'
// 版本文件列表
function getResourceList (data) {
  return axios({
    url: '/software-service/version/resource/list',
    method: 'get',
    params: data
  })
}
//暂停或开启svn地址获取软件包
function isGetResourceByPath (data) {
  return axios({
    url: '/software-service/version/resource/autoUpdatePack',
    method: 'post',
    data
  })
}
// 新增更新文件
function addResource (data) {
  return axios({
    url: '/software-service/version/resource',
    method: 'post',
    data
  })
}
// 编辑更新文件
function editResource (data) {
  return axios({
    url: '/software-service/version/resource',
    method: 'put',
    data
  })
}
// 删除更新文件
function deleteResource (data) {
  return axios({
    url: '/software-service/version/resource',
    method: 'delete',
    data
  })
}
// 停用启用更新文件
function enableResource (data) {
  return axios({
    url: '/software-service/version/resource/enable',
    method: 'put',
    data
  })
}
// 根据版本ID查询更新文件信息
function getResourceInfor (data) {
  return axios({
    url: '/software-service/version/resource/info',
    method: 'get',
    params: data
  })
}

/**
 * 获取低于指定版本的ECU版本列表及其文件信息（用于在线制作差分包-查询原始版本资源信息等）
 */
function getEcuVersionBefore (data) {
  return axios({
    url: '/software-service/version/resource/getResourceList',
    method: 'get',
    params: data
  })
}
// 在线差分保存
function diffResourceSave (data) {
  return axios({
    url: '/software-service/version/resource/diff',
    method: 'post',
    data: data
  })
}
// 在线差分批量保存
function diffResourceSaveBatch (data) {
  return axios({
    url: '/software-service/version/resource/batchDiff',
    method: 'post',
    data: data
  })
}
// 升级包文件进度
function resourceProcess (params) {
  return axios({
    url: '/software-service/version/resource/process',
    method: 'get',
    params
  })
}

// 在线差分重试
function diffRetry (data) {
  return axios({
    url: '/software-service/version/resource/diffRetry',
    method: 'post',
    data
  })
}

export default {
  getResourceList:getResourceList,
  addResource,
  editResource,
  deleteResource,
  enableResource,
  getResourceInfor,
  diffResourceSave,
  diffResourceSaveBatch,
  getEcuVersionBefore,
  diffResourceSave,
  resourceProcess,
  diffRetry,
  isGetResourceByPath
}
